import Map from './map'
import { districtName } from '@/data/map'

class District extends Map {
  constructor(...args) {
    super(...args)
  }

  // 区/县边界创建后
  afterCreatePolygon(polygon, gjson) {
    const name = gjson.properties.name

    if (!name || name == districtName) return

    // 鼠标经过
    polygon.on('mouseover', e => {
      polygon.setOptions({
        fillColor: this.config.bgHover,
      })

      if (this.options.onMouseover) this.options.onMouseover(name)
    })

    // 鼠标移除
    polygon.on('mouseout', e => {
      polygon.setOptions({
        fillColor: this.config.bg,
      })

      if (this.options.onMouseout) this.options.onMouseout()
    })
  }
}

export default District
